package com.youbug.mall.coupon_sms.controller;


import com.youbug.common.vo.QueryVo;
import com.youbug.mall.coupon_sms.entity.SmsSkuLadder;
import com.youbug.mall.coupon_sms.service.ISmsSkuLadderService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品阶梯价格 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-04-24
 */
@RestController
@RequestMapping("/smsSkuLadder")
public class SmsSkuLadderController {
@Autowired
private ISmsSkuLadderService smsSkuLadderService;

    @PostMapping("/getSmsSkuLadderPage")
    public R<IPage<SmsSkuLadder>> getSmsSkuLadderPage(@RequestBody QueryVo<SmsSkuLadder> queryVo){

        IPage<SmsSkuLadder> smsSkuLadders = smsSkuLadderService.getSmsSkuLadderPage(queryVo);

        return R.ok(smsSkuLadders);
    }

    @GetMapping("/getSmsSkuLadderById/{id}")
    public R<SmsSkuLadder> getSmsSkuLadderById(@PathVariable Integer id){

        SmsSkuLadder smsSkuLadder = smsSkuLadderService.getById(id);

        return R.ok(smsSkuLadder);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody SmsSkuLadder smsSkuLadder){

        boolean save = smsSkuLadderService.save(smsSkuLadder);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody SmsSkuLadder smsSkuLadder){

        boolean update = smsSkuLadderService.updateById(smsSkuLadder);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Integer id){

        boolean remove = smsSkuLadderService.removeById(id);

        return  R.ok(remove);
    }
}

